<script setup lang="ts">
import {ref} from 'vue';
import {Search, Refresh} from '@element-plus/icons-vue';
import {getInfomationInter} from "@/api/interface/interFace";
import {getActivityInfo} from "@/api/system/activity";
import {useRouter} from "vue-router";
import {getInfomation} from "@/api/system/infomation";
const router = useRouter();

const dialogVisible = ref(false);
const dataPick = ref('');
const getInfomationData=ref<getInfomationInter>({
    fromUsername: '',
    fromUserCompany: '',
    startTime: '',
    endTime: '',
    pageNum:1,
    pageSize:10
})
let infomationInfo = ref<object[]>([]);
let appInfototal = ref(0);
getInfomation(getInfomationData.value).then(res=>{
    console.log(res);
    infomationInfo.value?.push((res as any).rows);
    appInfototal.value = (res as any).total;
});

const handleCurrentChange = (val: number) => {
    console.log(`current page: ${val}`);
    getInfomationData.value.pageNum = val;
    infomationInfo.value.length = 0;
    getInfomation(getInfomationData.value).then(res => {
        console.log(res);
        infomationInfo.value?.push((res as any).rows);
    });
};
</script>
<template>
    <div>
        <div class="title" style="position: relative">
            <span class="inputTitle">姓名</span>
            <el-input
                v-model="getInfomationData.fromUsername"
                class="activeName"
                placeholder="请输入活动名称"
                clearable
                size="large"
            />
            <span class="inputTitle">公司名称</span>
            <el-input
                v-model="getInfomationData.fromUserCompany"
                class="activeName"
                placeholder="请输入活动名称"
                clearable
                size="large"
            />
            <span class="inputTitle" style="margin-left: 50px">沟通时间</span>
            <el-date-picker
                v-model="dataPick"
                type="daterange"
                value-format="YYYY-MM-DD"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                range-separator="至"
                class="dataInput"
                style="width: 300px"
                :default-value="[new Date(2024, 3, 24), new Date(2024, 3, 24)]"
            />
            <span class="btns">
            <el-button type="primary" :icon="Search" class="serachBtn"  >查询</el-button>
            <el-button :icon="Refresh" class="refreshBtn"   >重置</el-button>
        </span>
        </div>
        <section class='tableBox' style="padding: 0 30px">
            <el-table :data="(infomationInfo[0] as any)" style="width: 100%;margin-top: 50px" stripe>
                <template #empty>
                    <el-empty description="暂无数据"/>
                </template>
                <el-table-column prop="fromUsername" label="留言人"  height/>
                <el-table-column prop="toUsername" label="被留言人"  height/>
                <el-table-column prop="lastSendTime" label="最后沟通时间" height />
                >
                <el-table-column prop="操作" label="操作" height >
                    <template #default>
                        <button style="color: #1c84c6;margin-left: 10px">查看留言</button>
                        <button style="color: #1c84c6;margin-left: 10px" >删除留言</button>
                    </template>
                </el-table-column>
            </el-table>
        </section>
        <div style="position: relative">
            <span style="margin-left: 1000px;position: absolute;top: 8px">共{{appInfototal}}条数据</span>
            <el-pagination
                style="margin-top: 20px;margin-left: 1150px"
                :page-size="getInfomationData.pageSize"
                layout="prev, pager, next"
                :total="appInfototal"
                @currentChange="handleCurrentChange"
            />
        </div>


    </div>
</template>

<style scoped>
.addInfo {
    margin-top: 15vh !important;
    width: 40%;
    padding: 20px;
}

.addactiveName {
    width: 60%;
}

.btnClass {
    color: rgb(204, 196, 207) !important;
    cursor: no-drop;
}

.el-table .el-table__cell {
    padding: 18px !important;
}

.dialog {
    padding: 30px;
}

.cell {
    text-align: center !important;
    font-size: 14px;
}

.common-layout {
    margin-top: 40px;
    padding: 0 20px;
}

.el-header {
    background-color: rgb(248, 248, 249);
    height: 44px;
    font-size: 14px;
    font-weight: 600;
    color: #444;
    padding: 0 70px;
    line-height: 44px;
    border-bottom: 1px solid #d9d9d9;
}

.ulTitle {
    display: flex;
    justify-content: space-between;
}
li {
    list-style: none;
    float: left;
}

.btns {
    margin-left: 80px;
    position: absolute;
    bottom: -10px;
}

.serachBtn, .refreshBtn {
    width: 73px !important;
    height: 28px !important;
}

.demo-date-picker {
    display: flex;
    width: 100%;
    padding: 0;
    flex-wrap: wrap;
}

.demo-date-picker .block {
    padding: 30px 0;
    text-align: center;
    border-right: solid 1px var(--el-border-color);
    flex: 1;
}

.demo-date-picker .block:last-child {
    border-right: none;
}

.demo-date-picker .demonstration {
    display: block;
    color: var(--el-text-color-secondary);
    font-size: 14px;
    margin-bottom: 20px;
}

.title {
    height: 65px;
    border-bottom: 1px solid rgb(237, 237, 237);
    line-height: 65px;
    padding: 0 45px;
    overflow: hidden;
}

.inputTitle {
    font-size: 14px;
    font-weight: bolder;
    color: #666;

}

.activeName {
    width: 15%;
    margin-left: 15px;
    margin-right: 15px;
    height: 28px;
    font-size: 12px;
}

.el-date-editor .el-range-input {
    font-size: 12px;
}

.el-select-dropdown__item {
    width: 100% !important;
}



/deep/.el-form-item__label {
    width: 26%;
    font-weight: 700;
}
/deep/.cell{
    text-align: center;
}
</style>
